// 商品接口模拟
import { MockMethod } from 'vite-plugin-mock'

const productData = [
    {
        "id": 1,
        "goods_name": "Teenmix/天美意夏季专柜同款金色布女鞋6YF18BT6",
        "goods_price": 298,
        "tags": [
            "舒适",
            "透气"
        ],
        "inputVisible": false,
        "inputValue": ""
    },
    {
        "id": 2,
        "goods_name": "奥休斯(all shoes) 冬季保暖女士休闲雪地靴 舒适加绒防水短靴 防滑棉鞋子",
        "goods_price": 89,
        "tags": [
            "保暖",
            "防滑"
        ],
        "inputVisible": false,
        "inputValue": ""
    },
    {
        "id": 3,
        "goods_name": "初语秋冬新款毛衣女 套头宽松针织衫简约插肩袖上衣",
        "goods_price": 199,
        "tags": [
            "秋冬",
            "毛衣"
        ],
        "inputVisible": false,
        "inputValue": ""
    },
    {
        "id": 4,
        "goods_name": "佐露絲蕾丝衫女2020春秋装新款大码女装衬衫上衣雪纺衫韩版打底衫长袖",
        "goods_price": 19,
        "tags": [
            "雪纺衫",
            "打底"
        ],
        "inputVisible": false,
        "inputValue": ""
    },
    {
        "id": 5,
        "goods_name": "熙世界中长款长袖圆领毛衣女2022秋装新款假两件连衣裙女107SL170",
        "goods_price": 178,
        "tags": [
            "圆领",
            "连衣裙"
        ],
        "inputVisible": false,
        "inputValue": ""
    },
    {
        "id": 6,
        "goods_name": "烟花烫2021秋季装新品女装简约修身显瘦七分袖欧根纱连衣裙 花央",
        "goods_price": 282,
        "tags": [
            "秋季新品",
            "显瘦"
        ],
        "inputVisible": false,
        "inputValue": ""
    },
    {
        "id": 7,
        "goods_name": "韩都衣舍2021韩版女装秋装新宽松显瘦纯色系带长袖衬衫NG8201",
        "goods_price": 128,
        "tags": [
            "韩都衣舍",
            "长袖衬衫"
        ],
        "inputVisible": false,
        "inputValue": ""
    },
    {
        "id": 8,
        "goods_name": "预售纤莉秀大码女装胖妹妹秋装2020新款圆领百搭绣花胖mm休闲套头卫衣",
        "goods_price": 128,
        "tags": [
            "预售",
            "卫衣"
        ],
        "inputVisible": false,
        "inputValue": ""
    },
    {
        "id": 9,
        "goods_name": "莎密2022夏改良旗袍裙连衣裙修身复古时尚日常短款礼服旗袍",
        "goods_price": 128,
        "tags": [
            "莎密",
            "礼服"
        ],
        "inputVisible": false,
        "inputValue": ""
    },
    {
        "id": 10,
        "goods_name": "南极人秋冬韩版七彩棉加绒加厚一体保暖打底裤p7011",
        "goods_price": 128,
        "tags": [
            "南极人",
            "打底裤"
        ],
        "inputVisible": false,
        "inputValue": ""
    }
]

export default [
    {
        url: '/api/goods',
        method: 'get',
        timeout: 500,
        response: {
            code: 200,
            mes: '获取商品列表数据成功!',
            data: productData
        }
    },
    {
        url: '/api/goods',
        method: 'post',
        timeout: 50,
        response: ({ body }:{body:any}) => {
            // if (body) {
            //     if(userData.findIndex(item => item.name === body.name) !=  -1){
            //         return {
            //             code: 300,
            //             mes: '该用户名已经添加!'
            //         }
            //     }
            //     userData.push(body)
            //     return {
            //         code: 200,
            //         mes: '添加成功!'
            //     };
            // }
            // return {
            //     code: 500,
            //     mes: '添加失败请稍后再试!'
            // };
        }
    },
    {
        url: '/api/goods',
        method: 'delete',
        timeout: 50,
        response: ({ body }:{body:any}) => {
            if (body.id){
                const index = productData.findIndex(item => item.id == body.id)
                productData.splice(index,1)
                return {
                    code: 200,
                    mes: '删除成功!'
                };
            }
            return {
                code: 100,
                mes: '删除失败，请稍后在试！'
            }
        }
    }
] as MockMethod[]
